package helper;

import java.util.Properties;

import base.AppMemory;

/**
 * Proxy setzen 
 * @author Michel Metzger, Java-Kurs 2013
 * @version 1.0.0
 *
 */
public class Proxy {
	
	/**
	 * Setzt die evtl. erfordelichen Proxy-Einstellungen
	 */
	public static void setProxy() {
		if (AppMemory.getConfig() == null) {
			return;
		}
		
		if (AppMemory.getConfig().getProperty("proxy").compareTo("true") == 0) {
			Properties systemSettings = System.getProperties();
			systemSettings.put("proxySet", "true");
			if (!AppMemory.getConfig().getProperty("proxy_host").isEmpty()) {
				systemSettings.put("http.proxyHost", AppMemory.getConfig().getProperty("proxy_host"));
			}
			if (!AppMemory.getConfig().getProperty("proxy_port").isEmpty()) {
				systemSettings.put("http.proxyPort", AppMemory.getConfig().getProperty("proxy_port"));
			}
//			if (!AppMemory.getConfig().getProperty("proxy_type").isEmpty()) {
//				systemSettings.put("ProxyType", AppMemory.getConfig().getProperty("proxy_type"));
//			}
		}
	}
}
